﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HRM.DAL.DAO;
using HRM.DAL.Gateway;

namespace HRM.BLL
{
    public class ContactManager
    {
        ContactGateway gateway=new ContactGateway();
        public string SaveContactInfo(Contact contact)
        {
            int empId = gateway.HasContactInfoAlreadyExists(contact);
            if(empId>0)
            {
                return gateway.UpdateContact(empId,contact);
            }
            else
            {
                return gateway.SaveContact(contact);
            }
        }
        public Contact GetEmployeeContactInfo(Contact contact)
        {
            return gateway.GetEmployeeContactInfo(contact);
        }

        public List<Contact> GetAllEmployeesContactInfo(Contact contact)
        {
            return gateway.GetAllEmployeesContactInfo(contact);
        }
        public string UpdateContact(Contact contact)
        {
            EmployeeManager empManager=new EmployeeManager();
            int empId = empManager.GetEmployeeID(contact.Employee.EmpCode);
            return gateway.UpdateContact(empId, contact);
        }

    }
}